package com.beiding.utils;

public class RegexUtils {

    public final static String EMAIL_REGEX = "^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\\.[a-zA-Z0-9-]+)*\\.[a-zA-Z0-9]{2,6}$";

    public final static String PASSWORD_REGEX = "[a-zA-Z0-9]{5,15}";

    public final static String USERNAME_REGEX = "^[a-zA-Z][a-zA-Z0-9]{4,11}";

    public final static String AUTHORITY_REGEX = "^ROLE_[A-Z_]*";

    public final static String URI_REGEX = "^http[s]?://(([a-zA-Z0-9]+(\\.[a-zA-Z0-9]+)*)|(([0-9]+\\.){3}[0-9]+))(:[0-9]+)?(/[a-zA-Z0-9]+)*(\\?.+=.+(&.+=.+)*)?";


    public static boolean matchEmail(String email)
    {
        return email.matches(EMAIL_REGEX);
    }


    public static boolean matchPassword(String password)
    {
       return password.matches(PASSWORD_REGEX);
    }


    public static boolean matchUsername(String username)
    {
       return username.matches(USERNAME_REGEX);
    }


    public static boolean matchAuthority(String authority)
    {
        return authority.matches(AUTHORITY_REGEX);
    }

    public static boolean matchUri(String url)
    {
        return url.matches(URI_REGEX);
    }



    public static void main(String[] args) {

        System.out.println("1aefawefaef".matches(USERNAME_REGEX));

    }

}
